package com.bw.zg3.Cate.C1

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.bw.base.entity.C1EntityResultItem
import com.bw.base.net.ApiServer

@Suppress("UNUSED_EXPRESSION")
class ClSure(val apiServer: ApiServer):PagingSource<Int,C1EntityResultItem>() {
    override fun getRefreshKey(state: PagingState<Int, C1EntityResultItem>): Int? {
        return null
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, C1EntityResultItem> {
       try {
           val i = params.key ?: 0
           val c1 = apiServer.getC1()
           val i1 = if (c1.data.size == 10) i + 1 else null
          return LoadResult.Page(c1.data,null,i1)
       }catch (e:Exception){
            return LoadResult.Error(e)
       }
    }
}